package com.yanyu.space.file.feign;

import com.yanyu.space.common.core.bean.web.R;
import com.yanyu.space.common.core.constants.SpaceConstants;
import com.yanyu.space.file.bean.bo.*;
import com.yanyu.space.file.feign.fallback.FileClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author yanyu
 */
@FeignClient(name = "space-file",
        contextId = "space-file-1",
        fallbackFactory = FileClientFallbackFactory.class)
public interface IFileClient {

    @PostMapping(value = SpaceConstants.Feign.FEIGN_PREFIX_PATH + "/upload", produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<List<FileInfoBo>> directUpload(FileDirectSearchBo bo);

    @GetMapping(SpaceConstants.Feign.FEIGN_PREFIX_PATH + "/sharding")
    R<FileShardingInfoBo> shardingUpload(@RequestBody FileShardingSearchBo bo);

    @PostMapping(SpaceConstants.Feign.FEIGN_PREFIX_PATH + "/merge")
    R<FileInfoBo> shardingMergeUpload(@RequestBody FileShardingMergeSearchBo bo);
}
